New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Operation beautify error messages #1521
Operation beautify error messages #1521
Conversation
f3db36d
to
d4b23e0
Compare
Did you consider IDE integration as a design goal? Right now, the IDE has to consume error messages as string, which of course is suboptimal because we have a rich GUI and therefore more abilities to render error messages. Especially things like color codes, which are made for the console are completely useless for IDE consumption. What we need is more a tree like structure that contains all of the semantic information (like error message, erroneous tree, position etc.) not as strings but as real semantic objects, which could then be transferred to an IDE. Maybe this is out of scope for this proposal (especially because there is no presentation compiler anyway) but I would still like to attract some attention to it. |
@sschaef: both yes and no. The issue with IDE support is very open-ended and this could stretch the PR to absurdity. The current plan with this PR is to present an API for reporters that doesn't have to consume strings, but rather messages with semantic information (trees, symbols or whatever is relevant for the particular errors). But in the end they will be turned into strings and consumed by the console - at least for now. We will provide this framework - and then we're hoping to get the community involved in making these error messages top notch! 🎉 Dotty is designed from the very beginning with a presentation compiler in mind. There just haven't been resources enough to get the ball moving - but once this PR is done, next big thing we will tackle is the presentation compiler. Our current plan is to implement https://github.com/Microsoft/language-server-protocol |
Before you start to implement Microsofts protocol, I would like to have a chat with you (and the ensime people probably would want to know about this too), because you basically have to reimplement ensime and there are many things you can do wrong. |
We're always happy to collaborate - we'd love to have a word with both @fommil and you before we embark on this adventure. Sam has been very eager for us to start on this :) When we get closer to starting the work on the presentation compiler, I'll ping you both - so, let me know your details on gitter and we'll set up a friendly chat. |
I am very keen on a presentation compiler, yes :-) But I wouldn't say my enthusiasm extends to the Microsoft protocol because i feel that should be provided outside of the compiler. E.g. by ensime or another impl. Also, the protocol demands much more than just the ast (e.g. source code resolving, classpath search, other languages, reverse lookup) and you would start to implement ensime from scratch which is fine but i think you'd be taking on more than you want :-D (and that would significantly restrict what could be achieved because it's then tied to compiler release schedules) I'm on holiday for 3 weeks but if you are starting to spec out the presentation compiler please let's talk about ensime's requirements when we're both available. It could save you from implementing a lot of stuff, or missing something that would make our work easier! :-) // @rorygraves |
Is there another reasonably stable API by which the presentation compiler On Sun, Sep 18, 2016 at 8:22 PM, Sam Halliday notifications@github.com
Prof. Martin Odersky |
The VSC protocol is by far the best protocol that is out there right now, indeed (and it is the one that has most chances to get most successful). However, it has a design goal one should understand. It wants to be a protocol for lightweight IDE functionality, it doesn't aim to provide a feature set of a full fledged IDE like Eclipse or IntelliJ. Code completion or error highlighting are use cases the protocol wants to support. Because the tree of the compiler is not exposed as API, it is not possible that the consumer of the protocol implements its own functionality (like static analysis or refactorings). For scalac this has been different and Scala IDE and its feature set was made possible, even though exposing the trees came by a heavy price. By not exposing the trees, adopting the VSC protocol in the compiler is not attractive for Scala IDE - we simply wouldn't be able to support all of our rich features. The compiler could provide another API, just to make refactorings or static analysis possible but then the situation is mostly the same as in scalac. Because of the above I started to push a heavy redesign of Scala IDE (see https://www.reddit.com/r/scala/comments/52w7n8/future_of_scala_ide_would_you_like_to_see_an/), whose goal it is to not consume any PC in the first place. But this requires further elaboration on the design restrictions, which I do not want to give here, since we are in the wrong thread. ;) I see the VSC protocol in the compiler as a good middle ground for tools like the REPL/worksheet that want to provide some functionality of the compiler in an editor. But since ensime needs to be reimplemented in some parts in the compiler and since it is not realistic that Scala IDE is going to adopt the protocol, I'm not sure how attractive it is to spend time on implementing this in the first place. |
On Mon, Sep 19, 2016 at 12:53 PM, Simon Schäfer notifications@github.com
The problem with handing the tree out is that (a) trees are Cheers
Prof. Martin Odersky |
656f3d7
to
9080ffe
Compare
Making error message rendering pluggable would be great and allow tool specific rendering and outsourcing rendering to non-compiler-hackers. An intermediate storage format (json or else) is one way but has problems as @odersky pointed out. An alternative idea @tpolecat and I were discussing at Scala World would be providing rendering callbacks to the compiler. Similar to macros in a way as they would be run by the compiler, but going from the data of the situation to String, e.g. |
Discussion about the PC is continued in https://github.com/lampepfl/dotty/issues/1523 |
Not sure if the
It continues outside of the character range that is typed. |
This shows the same error multiple times:
|
I do not like that the error message no longer starts in column 0. I don't see a benefit in doing this. |
There's the flag |
if [ -z "$1" ]; then | ||
echo "Starting dotty REPL..." | ||
eval "$DOTTY_ROOT/bin/dotc -repl" | ||
elif [[ ${first_arg:0:1} == "-" ]]; then | ||
eval "$DOTTY_ROOT/bin/dotc -repl $@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sophisticated enough for now - we will have to revisit this script to get it on par with the scala
script eventually - see: #1526
In terms of integration with straight emacs etc (no ensime) it is really important that the file name, line number and column number (from 0) is available in an easily parseable form, typically colon delimited with some kind of identifier string like WARN or ERROR. For the pc, anything goes. |
@fommil: thank you for bringing attention to this. I assume it is the scala-mode2 being maintained as an (independent) part of Ensime? Currently the default reporter on master does not give a column at all - so this would need to be remedied anyhow for this to work. I'm curious as to what the functionality that depends on this is - and if said functionality can be improved. |
75f2e3e
to
949c974
Compare
The `CompilingInterpreter` will on a single compile run, make multiple parsings of the given line(s). This results in multiple warnings from the parser. As such, clear the warnings until the actual compile is performed.
6bd8138
to
b9e03b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smarter Indeed it was modeled after how scalac shows ConstantTypes. I think in the example you gave it's clearer than the alternatives.
ex"""reference to $name is ambiguous; | ||
|it is both ${bindingString(newPrec, ctx, "")} | ||
|and ${bindingString(prevPrec, prevCtx, " subsequently")}""", | ||
ex"""|reference to `$name` is ambiguous |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason for the first |
after the """?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're applying stripMargin
to the result of the string interpolation, the result is the same with or without the first |
.
I simply like it present since it can then be aligned with the other pipe symbols showing clearly what the resulting string will look like.
OK. I think it aligns just fine without the first On Mon, Oct 10, 2016 at 8:11 PM, Felix Mulder notifications@github.com
Prof. Martin Odersky |
We want to provide beautiful and above all helpful error messages to the users of dotty. We aspire to do just as well as Elm and Rust in this category and this PR is the first step in that direction.
This PR adds a few things to error messages of dotty:
-explain
flag-color:option
flag, never will give you aConsoleReporter
and the other options will give you the newFancyConsoleReporter
Syntax
andType
)hl"1 + 2"
for syntax highlightingConsole
directlyFancyConsoleReporter
and highlighting "color-aware"List[Map[A,C]]
diffList[Map[B,C]]
expanded2
and make sure that output fromex"$found"
is equal toMismatch(found)
compiling:
with
./bin/dotc -explain test.scala
yields:compiling:
yields: